package com.wswy.wyjk;

import android.support.multidex.MultiDex;

import com.facebook.stetho.Stetho;
import com.my.httpapi.api.baseUtils.HApi;
import com.my.httpapi.api.baseUtils.LogUtils;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
import com.wswy.wyjk.ui.share.ShareHelper;
import com.wswy.wyjk.ui.uitls.ChannelManager;
import com.tencent.mmkv.MMKV;
import com.wswy.wyjk.api.Constant;
import com.wswy.wyjk.core.AppInitializer;
import com.wswy.wyjk.core.location.LocManager;
import com.wswy.wyjk.utils.BasicConfige;

import java.util.HashMap;
import java.util.Map;

public class AppContext extends BasePartyAppContext {

    private static final Map<String, String> sConfigkeys = new HashMap<>();

    static {
        sConfigkeys.put(ConfigureKeys.BAIDU_MTJ_APPID, "1880d607ca");
        sConfigkeys.put(ConfigureKeys.BUGLY_APPID, Constant.buglyAppId);
    }

    @Override
    protected void initMainProcess() {
        super.initMainProcess();
        MultiDex.install(this);
        LocManager.getInstance().init(this).loadLocation();

        AppInitializer.init(this);

        Stetho.initializeWithDefaults(this);

        HApi.init(getContext(), BuildConfig.DEBUG);

        MMKV.initialize(this);

        inityoumeng();
        LogUtils.e("平台信息--->" + ChannelManager.getChannel(getContext()));
    }

    @Override
    public String getAppKey(String appKeyName) {
        return sConfigkeys.get(appKeyName);
    }


    private void inityoumeng() {
        //友盟统计
        UMConfigure.setLogEnabled(BuildConfig.DEBUG);
        UMConfigure.init(getContext(), BasicConfige.YOUMENGAPPKEY,
                ChannelManager.getChannel(getContext()),
                UMConfigure.DEVICE_TYPE_PHONE,
                "");

        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
        MobclickAgent.setCatchUncaughtExceptions(false);

        //微信
        PlatformConfig.setWeixin(ShareHelper.WX_APP_ID, ShareHelper.WX_APP_Secret_key);
    }
}
